﻿using System;
using System.Collections.Generic;

using System.Text;
using System.Data;

namespace Efficient.DataAccess
{
    public class DataParameter : IParameter
    {
        private object _value;
        private ParameterDirection direction = ParameterDirection.Input;
        private string name;

        public DataParameter(string name, ParameterDirection direction, object val)
        {
            this.name = name;
            this.direction = direction;
            this._value = val;
        }

        public DataParameter(string name, object val)
            : this(name, ParameterDirection.Input, val)
        { }

        public DataParameter(string name)
            : this(name, ParameterDirection.Input, null)
        { }

        #region IParameter Members

        public object Value
        {
            get { return _value; }
            set { _value = value; }
        }

        public string Name
        {
            get { return name; }
            set { name = value; }
        }

        public ParameterDirection Direction
        {
            get { return direction; }
            set { direction = value; }
        }

        public IDbDataParameter ToDbDataParameter(IDbService dao)
        {
            return dao.CreateParameter(this.name, this.direction, this._value);
        }

        #endregion
    }
}